package com.treeroot.treenet.strategy.init;

import com.treeroot.treenet.enums.ProtocolTypeMenu;
import com.treeroot.treenet.protocol.http.HandleHttpProtocol;
import com.treeroot.treenet.protocol.kcp.HandleKcpProtocol;
import com.treeroot.treenet.protocol.tcp.TcpConnection;
import com.treeroot.treenet.protocol.udp.HandleUdpProtocol;
import com.treeroot.treenet.protocol.ws.HandleWebSocketProtocol;
import com.treeroot.treenet.strategy.ProtocolStrategyHandle;

import java.util.Map;

/**
 * Create By TreeRoot
 * Create Time: 2023/12/18 03:46
 * Class Name: InitStrategyImpl
 * Description:
 * 策略具体初始化操作
 *
 * @author TreeRoot
 */
public class InitStrategyImpl implements InitStrategyService {
    @Override
    public Map<ProtocolTypeMenu, ProtocolStrategyHandle> getProtocolStrategyHandleMap() {
        return Map.of(
                ProtocolTypeMenu.WEBSOCKET, requestType -> new HandleWebSocketProtocol().handleRequest(ProtocolTypeMenu.WEBSOCKET),
                ProtocolTypeMenu.HTTP, requestType -> new HandleHttpProtocol().handleRequest(ProtocolTypeMenu.HTTP),
                ProtocolTypeMenu.TCP, requestType -> new TcpConnection().handleRequest(ProtocolTypeMenu.TCP),
                ProtocolTypeMenu.UDP, requestType -> new HandleUdpProtocol().handleRequest(ProtocolTypeMenu.UDP),
                ProtocolTypeMenu.KCP, requestType -> new HandleKcpProtocol().handleRequest(ProtocolTypeMenu.KCP)
        );
    }
}